package com.qut.atcoder.controller;

import com.qut.atcoder.mappers.UserQuestionMapper;
import com.qut.atcoder.pojo.UserQuestion;
import com.qut.atcoder.service.UserQuestionService;
import com.qut.atcoder.service.impl.UserQuestionServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class UserQuestionController {
    @Autowired(required = false)
    UserQuestionMapper userQuestionMapper;

    @Autowired(required = false)
    UserQuestionServiceImpl userQuestionService;

    @ResponseBody
    @RequestMapping("/answerTheQuestion")
    public int answerTheQuestion(@RequestBody UserQuestion userQuestion) {
        return userQuestionService.answer(userQuestion);
    }

    @ResponseBody
    @RequestMapping("/getUserAnswer")
    public List<UserQuestion> getUserAnswer(@RequestBody UserQuestion userQuestion) {
        return userQuestionMapper.selectUserQuestionByUserId(userQuestion);
    }
}
